﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Tokenizer.TokenizerView`3
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Globalization;
using System.Web.Razor.Resources;
using System.Web.Razor.Text;
using System.Web.Razor.Tokenizer.Symbols;

namespace System.Web.Razor.Tokenizer
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents the specified parameters for the tokenizer view.</summary>
  /// <typeparam name="TTokenizer">The type tokenizer.</typeparam>
  /// <typeparam name="TSymbol">The type symbol.</typeparam>
  /// <typeparam name="TSymbolType">The token symbol type.</typeparam>
  public class TokenizerView<TTokenizer, TSymbol, TSymbolType>
    where TTokenizer : System.Web.Razor.Tokenizer.Tokenizer<TSymbol, TSymbolType>
    where TSymbol : SymbolBase<TSymbolType>
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Tokenizer.TokenizerView`3" /> class.</summary>
    /// <param name="tokenizer">The tokenizer view.</param>
    public TokenizerView(TTokenizer tokenizer) => this.Tokenizer = tokenizer;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the tokenizer to view the symbols for the razor.</summary>
    /// <returns>The tokenizer to view the symbols for the razor.</returns>
    public TTokenizer Tokenizer { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets a value that indicates whether the view can reach the end of a file.</summary>
    /// <returns>true if the view can reach the end of a file; otherwise, false.</returns>
    public bool EndOfFile { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the current view of the TSymbol.</summary>
    /// <returns>The current view of the TSymbol.</returns>
    public TSymbol Current { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets the source of the text document for the tokenizer view.</summary>
    /// <returns>The source of the text document for the tokenizer view.</returns>
    public ITextDocument Source => (ITextDocument) this.Tokenizer.Source;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the tokenizer moves to the next view.</summary>
    /// <returns>true if the tokenizer moves to the next view; false.</returns>
    public bool Next()
    {
      this.Current = this.Tokenizer.NextSymbol();
      this.EndOfFile = (object) this.Current == null;
      return !this.EndOfFile;
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Puts a specified symbol into the tokenizer view.</summary>
    /// <param name="symbol">The symbol.</param>
    public void PutBack(TSymbol symbol)
    {
      if (this.Source.Position != symbol.Start.AbsoluteIndex + symbol.Content.Length)
        throw new InvalidOperationException(string.Format((IFormatProvider) CultureInfo.CurrentCulture, RazorResources.TokenizerView_CannotPutBack, (object) (symbol.Start.AbsoluteIndex + symbol.Content.Length), (object) this.Source.Position));
      this.Source.Position -= symbol.Content.Length;
      this.Current = default (TSymbol);
      this.EndOfFile = this.Source.Position >= this.Source.Length;
      this.Tokenizer.Reset();
    }
  }
}
